﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Web;

namespace XMK.Framework.Web
{
    public abstract class SecureHttpHandlerBase : IHttpHandler
    {
        private HttpContext _context;

        protected SecureHttpHandlerBase()
        {
        }

        public abstract void Process();
        public void ProcessRequest(HttpContext context)
        {
            this._context = context;
            this.Process();
        }

        //public void ValidateProduct(string productID)
        //{
        //    new AuthorizationManager(this._context).AuthorizeRequest(this.UserID, productID);
        //}

        public HttpContext Context
        {
            get
            {
                return this._context;
            }
        }

        public virtual bool IsReusable
        {
            get
            {
                return false;
            }
        }

        public string UserID
        {
            get
            {
                return Convert.ToString(this._context.Items["____userid"]);
            }
        }

        //public List<NameValueItem> UserInfo
        //{
        //    get
        //    {
        //        return (this.Context.Items["____userinfo"] as List<NameValueItem>);
        //    }
        //}
        public Dictionary<string, string> UserInfo
        {
            get
            {
                return (this.Context.Items["____userinfo"] as Dictionary<string, string>);
            }
        }
    }
}
